package com.ycsj.goldmedalnewconcept.parent.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.parent.bean.LeaveInfo;

import java.util.List;


/**
 * 在线请假列表适配器
 * Created by Administrator on 2018/6/20 0020.
 */

public class LeaveRvAdapter extends BaseQuickAdapter<LeaveInfo.DataBean, BaseViewHolder> {
    private Context context;


    public LeaveRvAdapter(Context context, int layoutResId, @Nullable List<LeaveInfo.DataBean> data) {
        super(layoutResId, data);
        this.context = context;
    }


    @Override
    protected void convert(BaseViewHolder helper, LeaveInfo.DataBean item) {
        //创建时间
        TextView tvCreateTime = helper.getView(R.id.tv_time);
        tvCreateTime.setText(item.getCreatetime());

        //请假时间
        TextView tvDate = helper.getView(R.id.tv_date);
        tvDate.setText(item.getBegindate() + "~" + item.getEnddate());

        //请假缘由
        TextView tvReason = helper.getView(R.id.tv_reason);
        tvReason.setText(item.getContent());

        //状态标签
        TextView tvState = helper.getView(R.id.tv_state);
        if ("0".equals(item.getStatus())) {
            //待批准
            tvState.setText("待批准");
            tvState.setBackgroundResource(R.drawable.parent_state_dpz);
        } else if ("1".equals(item.getStatus())) {
            //已批准
            tvState.setText("已批准");
            tvState.setBackgroundResource(R.drawable.parent_state_ypz);
        }
    }
}
